#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int my_atoi(char* str)
{
	assert(str);
	char* tmp = str;
	while (isspace(*tmp))
	{
		tmp++;
	}
	int num = 0;
	while (*tmp >= 48 && *tmp <= 57)
	{
		num = num * 10 + (*tmp - '0');
		if (*(tmp + 1) < 48 || *(tmp + 1) > 57)
			return num;
		tmp++;
	}
	return 0;
}

int main()
{
	char arr[] = "          9876bnjdf99n";
	printf("%d", my_atoi(arr));
	return 0;
}